import { View, Text, Button } from '@tarojs/components'
import { useLocalStore,Observer} from 'mobx-react'
import { useEffect } from 'react'

import store from '../../store/index'
import './index.scss'

export default function Index() {
  const myStore = useLocalStore(() => store)
  useEffect(() => {
    console.log('首页中获取props:>>>',myStore.count)
  }, [myStore.count])

  // return useObserver(() => (
  //   <View className='index'>
  //     <Text>Hello world! { myStore.count }</Text>
  //     <Button onClick={myStore.increment}>点击加一</Button>
  //   </View>
  // ))
  return (
    <Observer>
      {
        () => (
          <View className='index'>
            <Text>Hello world! { myStore.count }</Text>
            <Button onClick={myStore.increment}>点击加一</Button>
            <Button onClick={myStore.decreament}>点击减一</Button>
          </View>
        )
      }
    </Observer>
  )
}